package com.exartisan.network;

import android.app.AlertDialog;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;


/**
 * The Class NetworkUtility.
 * @author anh
 */
public class NetworkUtility {
	
	public static final int DEFAULT_TIME_OUT = 10000;
	
	//app
	
	public static String API_URL = "";
	public static final String HANDLE = "handle";
	public static final String SUCCESS = "success";
	public static final String DATA = "data";
	public static final String TOP_EVENT = "top_event";
	public static final String NEW_EVENT = "new_event";
	public static final String GALLERY_INFO = "gallery_info";
	public static final String EVENT_GALLERY = "event_gallery";
	public static final String DETAIL_EVENT = "detail_event";
	public static final String ID = "ID";
	public static final String ERROR_MESSAGE = "message";
	public static final String ERROR_CODE = "errorCode";
	public static final String EVENTNAME = "EvenName";
	public static final String EVENTNAME2 = "EventName";
	public static final String STARTDATE = "StartDate";
	public static final String ENDDATE = "EndDate";
	public static final String THUMBURL = "ImgPresent";
	public static final String MEDIA_URL = "MediaLink";
	public static final String MEDIA_TITLE = "MediaTitle";
	public static final String DESCRIPTION = "Summary";
	public static final String EVENTID = "EventID";
	public static final String TYPE = "Type";
	public static final String LIKES = "Likes";
	public static final String COMMENTS = "Comments";
	public static final String COVERULR = "CoverUrl";
	public static final String PLACE = "Location";
	public static final String ARTICLE = "Contents";
	public static final String CONTACTURL = "ContactUrl";
	public static final String URL = "Url";
	public static final String REQUEST_EVENT_ID = "event_id";
	public static final String REQUEST_ID = "id";
	public static final String ON_SYSTEM_ERROR = "on_system_error";
	public static final String QUESTION = "questions";
	public static final String TABLE = "Table";
	public static final String FEEDID = "FeedID";
	
	//tunm
	public static final String HANDLE_CATEGORY = "on_get_category";
	 public static final String HANDLE_EVENT = "on_get_events";
	 public static final String HANDLE_POST = "on_get_posts";
	 public static final String HANDLE_DETAIL_GALLERY = "on_get_gallerys";
	 public static final String PARENT_TYPE = "ParentType";
	 public static final String PARENT_ID = "ParentID";
	 public static final String HANDLE_CATEGORY_FORUM = "on_get_category_forum";
	 public static final String HANDLE_SURVEY = "on_get_survey";
	 public static final String HANDLE_QUESTION = "on_get_question";
	 public static final String SURVEY_ID = "SurveyID";
	 public static final String STATUS = "Status";
	
	//vanvd_CATEGORY
	 public static final String CATEGORY_ID = "CategoryID";
	 public static final String CATEGORY_NAME = "CategoryName";
	 public static final String CATEGORY_IMG = "CategoryImg";
	 public static final String CATEGORY_IMG_THUMB = "CategoryImgThumb";
	 
	 //vanvd_Event
	 public static final String DATE_CREATE = "DateCreate";
	 public static final String DATE_START = "DateStart";
	 public static final String DATE_END = "DateEnd";
	 public static final String IMG = "Image";
	 public static final String IMGS = "Images";
	 public static final String IMG_THUMB = "ImageThumb";
	 public static final String EVENT_CONTENT = "EventContent";
	 public static final String EVENT_ADDRESS = "EventAddress";
	 public static final String EVENT_WEB_VIEW_URL = "http://toiyeuhanoi.org.vn/event/viewmobileevent/";
	 
	 //vanvd_Post
	public static final String POST_ID = "PostID";
	public static final String POST_TYPE = "PostType";
	public static final String POST_DESCRIPTION = "PostDescription";
	public static final String POST_CONTENT = "PostContent";
	public static final String USER_CREATE = "UserCreate";
	public static final String POST_TITLE = "PostTitle";
	public static final String POST_USER_NAME = "UserDisplayName";
	public static final String POST_USER_AVATAR_URL = "UserAvatarLink";
	public static final String POST_WEB_VIEW_URL = "http://toiyeuhanoi.org.vn/blog/viewmobilepost/";
	
	//vanvd_gallery
	public static final String MEDIA_ID = "MediaID";
	public static final String MEDIA_DESCRIPTION = "MediaDescription";
	public static final String MEDIA_TYPE = "MediaType";
	public static final String MEDIA_LINK = "MediaLink";

	//vanvd_category4rum
	public static final String CAT_ID = "CatID";
	public static final String CAT_TITLE = "CatTitle";
	
	//vanvd_survey
	public static final String SURVEY_NAME = "SurveyName";
	
	//vanvd_questions
	public static final String QUESTION_ID = "QuestionID";
	public static final String QUESTION_NAME = "QuestionName";
	public static final String QUESTION_TYPE = "QuestionType";
	//Fb
	
	
	public static final String GRAPH_API_URL = "https://graph.facebook.com";
	public static final String IDS = "ids";
	public static final String FACEBOOK_FEED_ID = "FacebookFeedID";
	public static final String PAGING = "paging";
	public static final String FACEBOOK_COMMENT_ID = "id";
	public static final String FACEBOOK_COMMENT = "message";
	public static final String CREATED_TIME = "created_time";
	public static final String FACEBOOK_FROM = "from";
	public static final String FACEBOOK_USER_ID = "id";
	public static final String FACEBOOK_USER_NAME = "name";
	public static final String FACEBOOK_LIKE_COUNT = "like_count";
	public static final String FACEBOOK_NEXT_CMT_PAGE = "next";
	public static final String FACEBOOK_PRE_CMT_PAGE = "previous";
	public static final String FACEBOOK_PROFILE_PICTURE = "picture";
	public static final String FACEBOOK_PICTURE_URL = "url";
	public static final String SUMMARY = "summary";
	public static final String TOTAL_COUNT = "total_count";
	public static final String CONNECTION_COMMENT = "comments";
	public static final String CONNECTION_LIKE = "likes";
	
	public static final String COMMENTAPI = "http://dogoanthinh.com/thuongnv/facebookapi.php";

	
	
	
	
	
	/**
	 * Instantiates a new network utility object.
	 */
	public NetworkUtility() {
		
	}
	
	/**
	 * Check the network state.
	 *
	 * @param context the context to check network on
	 * @return true, if has usable network
	 */
	public static boolean checkNetworkState(Context context){
		ConnectivityManager conMgr =  (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo i = conMgr.getActiveNetworkInfo();
		  if (i == null)
		    return false;
		  if (!i.isConnected())
		    return false;
		  if (!i.isAvailable())
		    return false;
		return true;
	}
	
	/**
	 * Show a dialog which inform no Internet connection.
	 *
	 * @param context the context to show this dialog on
	 */
	public static void showNoNetworkDialog(Context context){
		AlertDialog.Builder restartAlertBuilder = new AlertDialog.Builder(context);
		restartAlertBuilder.setTitle("Không có kết nối mạng");
		restartAlertBuilder.setMessage("Vui lòng bật kết nối internet");
		restartAlertBuilder.setCancelable(false);
		restartAlertBuilder.setPositiveButton("Ok", null);
		
		AlertDialog restartAlertDialog = restartAlertBuilder.create();
		restartAlertDialog.show();
	}
	
	/**
	 * Show a dialog which inform the connection attempt reached it time out.
	 *
	 * @param context the context to show this dialog on
	 */
	public static void showTimeOutDialog(Context context){
		AlertDialog.Builder restartAlertBuilder = new AlertDialog.Builder(context);
		restartAlertBuilder.setTitle("Kết nối lỗi");
		restartAlertBuilder.setMessage("Không thể kết nối với server, vui lòng thử lại");
		restartAlertBuilder.setCancelable(false);
		restartAlertBuilder.setPositiveButton("Ok", null);
		
		AlertDialog restartAlertDialog = restartAlertBuilder.create();
		restartAlertDialog.show();
		
	}
	
	public static void showDialog(Context context, String title, String message){
		AlertDialog.Builder restartAlertBuilder = new AlertDialog.Builder(context);
		restartAlertBuilder.setTitle(title);
		restartAlertBuilder.setMessage(message);
		restartAlertBuilder.setCancelable(false);
		restartAlertBuilder.setPositiveButton("Ok", null);
		AlertDialog restartAlertDialog = restartAlertBuilder.create();
		restartAlertDialog.show();
		
	}

}
